<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/css/H-ui.admin.css">
    <link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/style.css">
    <script type="text/javascript" src="${ctx}/appjs/channel/channelLevel.js"></script>
    <style>
        .form-group img {
            cursor: pointer
        }
    </style>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>渠道商等级规则</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>编辑渠道商等级</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">编辑渠道商等级</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frm">
                        <input id="channelLevel" name="channelLevel" value="${channelLevelSetting.channelLevel}" type="hidden">
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">等级名称：</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="levelTypeName" value="${channelLevelSetting.levelTypeName}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">企业标识图标：</label>
                            <div class="col-sm-8">
                                <div >
                                    <c:choose>
                                        <c:when test="${channelLevelSetting.levelLogo !=null && channelLevelSetting.levelLogo != ''}">
                                            <div>
                                                <img id="levelLogo" src="${channelLevelSetting.levelLogo}" width="155px" height="120px">
                                            </div>
                                        </c:when>
                                        <c:otherwise>
                                            <div>
                                                <img id="levelLogo" src="${ctx}/statics/img/upload-img.png"
                                                     style="position: relative" width="155px" height="120px">
                                            </div>
                                        </c:otherwise>
                                    </c:choose>
                                    <input type="file" id="file1" name="file1"/>
                                </div>
                                <span>图片尺寸建议为：<span class="text-danger">98px*75px</span></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">累计卖卡：</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="saleCardTarget" value="${channelLevelSetting.saleCardTarget}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-success">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">


    $("#file1").change(function () {
        var file = this.files[0];
        var reg = RegExp(/image/);
        if (!reg.test(file.type)) {
            parent.layer.msg("支持图片上传");
            return;
        }
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#levelLogo").attr("src", objUrl);
        }
    });

    $("#file2").change(function () {
        var file = this.files[0];
        var reg = RegExp(/image/);
        if (!reg.test(file.type)) {
            parent.layer.msg("支持图片上传");
            return;
        }
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#companyImg2").attr("src", objUrl);
        }
    });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

    editChannelLevel.init();
</script>
</body>
</html>
